<!doctype html>
<html lang="zh-CH">
<head>
	<meta charset="UTF-8">
	<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
	<meta name="viewport" content="width=device-width, initial-scale=1">
	<title>央票通</title>
	<link rel="stylesheet" href="./resource/css/index.css">
	<link rel="stylesheet" href="./resource/css/user.css">
</head>
<body>
<!-- 头部 -->
@include('common.index_head')
<!-- 个人中心 -->
<div class="cont-user">
	<!-- 个人中心头部 -->
	@include('common.user_head')
	<div class="user-center">
		<div class="main">
			<!-- 个人中心列表 -->
			@include('common.user_left')
			<div class="user-container left" >
				<div class="user-title user-password user-news">
					<div class="title">
						<div class="h left">消息列表</div>
					</div>
					<div class="user-box" >
						<ul class="pass-ul">
							<li class="active"><a href="javascript:;">全部</a></li>
							<li><a href="javascript:;">未读</a></li>
							<li><a href="javascript:;">已读</a></li>
						</ul>
						<div class="pass-main">
							<div class="pass-cont" >
								<ul class="news-ul" id="one">
									<li>
										<input type="checkbox" class="checkAll checkAll1" > 全选
										<a href="javascript:;" onclick="del_all()">删除</a>
										<div class="right">
											<span class="unread-num">未读<?echo count($unread)?></span>
											<span class="all-num"> / 全部<?echo count($all)?></span>
										</div>
									</li>
									<div id="list1">
									@foreach($all as $k=>$v)
										<li class="unread" ro="hide" >
											<input type="checkbox" name="check1" id="check1" value="{{$v->message_id}}">
											<div class="news-title left">{{$v->title}}</div>
											<div class="news-time right">{{date('Y-m-d H:i:s',$v->created)}}</div>
											<p class="news-cont">{{$v->content}}</p>
										</li>
									@endforeach
									</div>
								</ul>
							</div>
							<div class="pass-cont" >
								<ul class="news-ul" id="two">
									<li>
										<input type="checkbox" class="checkAll checkAll2" > 全选
										<a href="javascript:;" onclick="del_unread()">删除</a>
										<div class="right">
											<span class="unread-num">未读<?echo count($unread)?></span>
											<span class="all-num"> / 全部<?echo count($all)?></span>
										</div>
									</li>
									<div id="list2">
									@foreach($unread as $k=>$v)
											<li class="unread" ro="hide">
												<input type="checkbox" name="check2" id="check2" value="{{$v->message_id}}">
												<div class="news-title left">{{$v->title}}</div>
												<div class="news-time right">{{date('Y-m-d H:i:s',$v->created)}}</div>
												<p class="news-cont">{{$v->content}}</p>
											</li>
									@endforeach
									</div>
								</ul>
							</div>
							<div class="pass-cont" >
								<ul class="news-ul" id="three">
									<li>
										<input type="checkbox" class="checkAll checkAll3" > 全选
										<a href="javascript:;" onclick="del_read()">删除</a>
										{{--<a href="javascript:;" class="delete"  >删除</a>--}}
										<div class="right">
											<span class="unread-num">未读<?echo count($unread)?></span>
											<span class="all-num"> / 全部<?echo count($all)?></span>
										</div>
									</li>
									<div id="list3">
									@foreach($read as $k=>$v)
											<li class="unread" ro="hide" >
												<input type="checkbox" name="check3" id="check3" value="{{$v->message_id}}">
												<div class="news-title left">{{$v->title}}</div>
												<div class="news-time right">{{date('Y-m-d H:i:s',$v->created)}}</div>
												<p class="news-cont">{{$v->content}}</p>
											</li>
									@endforeach
									</div>
								</ul>
							</div>
						</div>
					</div>
				</div>
			</div>
		</div>
	</div>
</div>

<!-- footer -->
@include('common.index_foot')
<script src="./resource/js/jquery-1.11.3.min.js"></script>
<script src="./resource/js/index.js"></script>
<script src="./resource/js/user.js"></script>
<script type="text/javascript">
	function del_all(){
		var checks = document.getElementsByName("check1");
		var n = '';
		for (var i = 0; i < checks.length; i++) {
			if (checks[i].checked)
				n += checks[i].value + ','
		}
		var num = n.substring(0, (n.length) - 1);
		var msg = "您真的确定要删除吗？";
		if (confirm(msg) == true) {
			$.ajax({
				type: "POST",
				url: "/user_news_del1",
				data: "num="+num,
				success: function(msg){
					$('#list1').html(msg)
				}
			});
		}
	}
	function del_unread(){
		var checks = document.getElementsByName("check2");
		var n = '';
		for (var i = 0; i < checks.length; i++) {
			if (checks[i].checked)
				n += checks[i].value + ','
		}
		var num = n.substring(0, (n.length) - 1);
		var msg = "您真的确定要删除吗？";
		if (confirm(msg) == true) {
			$.ajax({
				type: "POST",
				url: "/user_news_del2",
				data: "num="+num,
				success: function(msg){
					$('#list2').html(msg)
				}
			});
		}
	}
	function del_read(){
		var checks = document.getElementsByName("check3");
		var n = '';
		for (var i = 0; i < checks.length; i++) {
			if (checks[i].checked)
				n += checks[i].value + ','
		}
		var num = n.substring(0, (n.length) - 1);
		var msg = "您真的确定要删除吗？";
		if (confirm(msg) == true) {
			$.ajax({
				type: "POST",
				url: "/user_news_del3",
				data: "num="+num,
				success: function(msg){
					$('#list3').html(msg)
				}
			});
		}
	}
</script>
</body>
</html>